// boolean 值，true/false
let isDone: boolean = true
let hasData: boolean = false

// number 值，浮点型
let decLiteral: number = 123;
let hexLiteral: number = 0xf00d;
let binaryLiteral: number = 0b1010;
let octalLiteral: number = 0o744;

// string 字符串值
let firstName: string = 'jane';
firstName = 'smith';

let myName: string = `mike`;
let age: number = 37;
let info: string = `Hello, my name is ${myName}; I'm ${age} years old.`

// 数组 array，
let list: number[] = [1, 2, 3];
let list01: Array<number> = [4, 5, 6]

// 元组 tuple
let x: [string, number];
x = ['hello', 20];
x = ['mike', 30];

// 枚举类型 enum
// 1. 默认从0开始
// enum Color {
//   Red,
//   Green,
//   Blue
// }
// 2. 也可指定开始编号
// enum Color {
//   Red = 1,
//   Green,
//   Blue
// }
// 3. 也可手动赋值
enum Color {
  Red = 1,
  Green = 4,
  Blue = 6
}
let color: Color = Color.Red;

// 从值来获取枚举的名字
let colorName: string = Color[1]


// any 类型
let notSure: any = 4;
notSure = 'mike';
notSure = false;

// void 类型
function func(): void {
}
let unusable: void = undefined;
let unusable01: void = null;
// let unusable02: void = 1;

// null 和 undefined
let u: undefined = undefined;
let n: null = null;
let v: void = null;
let v01: void = undefined;

// never 类型
function error(message: string): never {
  throw new Error(message);
}
function fail(): never {
  return error('Something failed')
}
function infiniteLoop(): never {
  while(true) {
  }
}
let funcnv: never = (() => {
  throw new Error('Typescript never');
})();

let bar: never = (() => { throw new Error('TypeScript never'); })();